<?php
/**
 * Created by PhpStorm .
 * User: 杜磊磊
 * Date: 2020/6/27
 * Time: 10:49
 */
declare(strict_types=1);
namespace app\api\controller;

use app\BaseController;
use app\common\business\Sms as SmsBus;

class Sms extends BaseController
{
    public function code() :object
    {
        $phoneNumber = input('phone_number','','trim');
        $data = [
            'phone_number' => $phoneNumber
        ];
        //return 1111;
        try {
            validate(\app\api\validate\User::class)->scene("send_code")->check($data);
        }catch (\think\exception\ValidateException $e ){
            return show(config('status.error'),$e->getError());
        }
        //调用business层的数据
        if (SmsBus::sendCode($phoneNumber,4,"ali")){
            return show(config("status.success"),"发送验证码成功");
        }
        return show(config("status.error"),"发送验证码失败");
    }
}